Hệ thống xếp lịch học tín chỉ cho sinh viên CNTT trên PHP & MySQL
111.107 lượt xem;
- membership_profile.php
- project /
1 <?php
2 $currDir=dirname(__FILE__);
3 include("$currDir/defaultLang.php");
4 include("$currDir/language.php");
5 include("$currDir/lib.php");
6
7 $adminConfig = config('adminConfig');
8
9 /* no access for guests */
10 $mi = getMemberInfo();
11 if(!$mi['username'] || $mi['group'] == $adminConfig['anonymousGroup']){
12 @header('Location: index.php'); exit;
13 }
14
15 /* save profile */
16 if($_POST['action'] == 'saveProfile'){
17 if(!csrf_token(true)){
18 echo $Translation['error:'];
19 exit;
20 }
21
22 /* process inputs */
23 $email=isEmail($_POST['email']);
24 $custom1=makeSafe($_POST['custom1']);
25 $custom2=makeSafe($_POST['custom2']);
26 $custom3=makeSafe($_POST['custom3']);
27 $custom4=makeSafe($_POST['custom4']);
28
29 /* validate email */
30 if(!$email){
31 echo "{$Translation['error:']} {$Translation['email invalid']}";
32 echo "<script>$$('label[for=\"email\"]')[0].pulsate({ pulses: 10, duration: 4 }); $('email').activate();</script>";
33 exit;
34 }
35
36 /* update profile */
37 $updateDT = date($adminConfig['PHPDateTimeFormat']);
38 sql("UPDATE `membership_users` set email='$email', custom1='$custom1', custom2='$custom2', custom3='$custom3', custom4='$custom4', comments=CONCAT_WS('\\n', comments, 'member updated his profile on $updateDT from IP address {$mi[IP]}') WHERE memberID='{$mi['username']}'", $eo);
39
40 // hook: member_activity
41 if(function_exists('member_activity')){
42 $args=array();
43 member_activity($mi, 'profile', $args);
44 }
45
46 exit;
47 }
48
49 /* change password */
50 if($_POST['action'] == 'changePassword' && $mi['username'] != $adminConfig['adminUsername']){
51 if(!csrf_token(true)){
52 echo $Translation['error:'];
53 exit;
54 }
55
56 /* process inputs */
57 $oldPassword=$_POST['oldPassword'];
58 $newPassword=$_POST['newPassword'];
59
60 /* validate password */
61 if(md5($oldPassword) != sqlValue("SELECT `passMD5` FROM `membership_users` WHERE memberID='{$mi['username']}'")){
62 echo "{$Translation['error:']} {$Translation['Wrong password']}";
63 echo "<script>$$('label[for=\"old-password\"]')[0].pulsate({ pulses: 10, duration: 4 }); $('old-password').activate();</script>";
64 exit;
65 }
66 if(strlen($newPassword) < 4){
67 echo "{$Translation['error:']} {$Translation['password invalid']}";
68 echo "<script>$$('label[for=\"new-password\"]')[0].pulsate({ pulses: 10, duration: 4 }); $('new-password').activate();</script>";
69 exit;
70 }
71
72 /* update password */
73 $updateDT = date($adminConfig['PHPDateTimeFormat']);
74 sql("UPDATE `membership_users` set `passMD5`='".md5($newPassword)."', `comments`=CONCAT_WS('\\n', comments, 'member changed his password on $updateDT from IP address {$mi[IP]}') WHERE memberID='{$mi['username']}'", $eo);
75
76 // hook: member_activity
77 if(function_exists('member_activity')){
78 $args=array();
79 member_activity($mi, 'password', $args);
80 }
81
82 exit;
83 }
84
85 /* get profile info */
86 /*
87 $mi already contains the profile info, as documented at:
88 https://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
89
90 custom field names are stored in $adminConfig['custom1'] to $adminConfig['custom4']
91 */
92 $permissions = array();
93 $userTables = getTableList();
94 if(is_array($userTables)) foreach($userTables as $tn => $tc){
95 $permissions[$tn] = getTablePermissions($tn);
96 }
97
98 /* the profile page view */
99 include_once("$currDir/header.php"); ?>
100
101 <div class="page-header">
102 <h1><?php echo sprintf($Translation['Hello user'], $mi['username']); ?></h1>
103 </div>
104 <div id="notify" class="alert alert-success" style="display: none;"></div>
105 <div id="loader" style="display: none;"><i class="glyphicon glyphicon-refresh"></i> <?php echo $Translation['Loading ...']; ?></div>
106
107 <?php echo csrf_token(); ?>
108 <div class="row">
109
110 <div class="col-md-6">
111
112 <!-- user info form -->
113 <div class="panel panel-info">
114 <div class="panel-heading">
115 <h3 class="panel-title">
116 <i class="glyphicon glyphicon-info-sign"></i>
117 <?php echo $Translation['Your info']; ?>
118 </h3>
119 </div>
120 <div class="panel-body">
121 <fieldset id="profile">
122 <div class="form-group">
123 <label for="email"><?php echo $Translation['email']; ?></label>
124 <input type="email" id="email" name="email" value="<?php echo $mi['email']; ?>" class="form-control">
125 </div>
126
127 <?php for($i=1; $i<5; $i++){ ?>
128 <div class="form-group">
129 <label for="custom<?php echo $i; ?>"><?php echo $adminConfig['custom'.$i]; ?></label>
130 <input type="text" id="custom<?php echo $i; ?>" name="custom<?php echo $i; ?>" value="<?php echo $mi['custom'][$i-1]; ?>" class="form-control">
131 </div>
132 <?php } ?>
133
134 <div class="row">
135 <div class="col-md-4 col-md-offset-4">
136 <button id="update-profile" class="btn btn-success btn-block" type="button"><i class="glyphicon glyphicon-ok"></i> <?php echo $Translation['Update profile']; ?></button>
137 </div>
138 </div>
139 </fieldset>
140 </div>
141 </div>
142
143 <!-- access permissions -->
144 <div class="panel panel-info">
145 <div class="panel-heading">
146 <h3 class="panel-title">
147 <i class="glyphicon glyphicon-lock"></i>
148 <?php echo 'Quản lý quyền truy cập';//$Translation['Your access permissions']; ?>
149 </h3>
150 </div>
151 <div class="panel-body">
152
153 <div class="row">
154 <div class="col-xs-2 col-md-1 text-right"><img src="admin/images/stop_icon.gif"></div>
155 <div class="col-xs-10 col-md-5"><?php echo 'Không cho phép';//$Translation['Not allowed']; ?></div>
156 <div class="col-xs-2 col-md-1 text-right"><img src="admin/images/member_icon.gif"></div>
157 <div class="col-xs-10 col-md-5"><?php echo 'Chỉ mình bạn được quyền này';//$Translation['Only your own records']; ?></div>
158 </div>
159 <div class="row">
160 <div class="col-xs-2 col-md-1 text-right"><img src="admin/images/members_icon.gif"></div>
161 <div class="col-xs-10 col-md-5"><?php echo 'Nhóm bạn quản lý';//$Translation['All records owned by your group']; ?></div>
162 <div class="col-xs-2 col-md-1 text-right"><img src="admin/images/approve_icon.gif"></div>
163 <div class="col-xs-10 col-md-5"><?php echo 'Tất cả các quyền';// $Translation['All records']; ?></div>
164 </div>
165
166 <p class="vspacer-lg"></p>
167
168 <div class="table-responsive">
169 <table class="table table-striped table-hover table-bordered" id="permissions">
170 <thead>
171 <tr>
172 <th></th>
173 <!--
174 <th class="text-center"><?php echo $Translation['View']; ?></th>
175 <th class="text-center"><?php echo $Translation['Add New']; ?></th>
176 <th class="text-center"><?php echo $Translation['Edit']; ?></th>
177 <th class="text-center"><?php echo $Translation['Delete']; ?></th>
178
179 -->
180 <th class="text-center"><?php echo 'Xem'; ?></th>
181 <th class="text-center"><?php echo 'Thêm mới'; ?></th>
182 <th class="text-center"><?php echo 'Sửa'; ?></th>
183 <th class="text-center"><?php echo 'Xóa'; ?></th>
184
185 </tr>
186 </thead>
187 <tbody>
188 <?php foreach($permissions as $tn => $perm){ ?>
189 <tr>
190 <td><img src="<?php echo $userTables[$tn][2]; ?>"> <a href="<?php echo $tn; ?>_view.php"><?php echo $userTables[$tn][0]; ?></a></td>
191 <td class="text-center"><img src="admin/images/<?php echo permIcon($perm[2]); ?>" /></td>
192 <td class="text-center"><img src="admin/images/<?php echo ($perm[1] ? 'approve' : 'stop'); ?>_icon.gif" /></td>
193 <td class="text-center"><img src="admin/images/<?php echo permIcon($perm[3]); ?>" /></td>
194 <td class="text-center"><img src="admin/images/<?php echo permIcon($perm[4]); ?>" /></td>
195 </tr>
196 <?php } ?>
197 </tbody>
198 </table>
199 </div>
200 </div>
201 </div>
202
203 </div>
204
205 <div class="col-md-6">
206
207 <!-- group and IP address -->
208 <div class="panel panel-info">
209 <div class="panel-body">
210 <div class="form-group">
211 <label><?php echo $Translation['Your IP address']; ?></label>
212 <div class="form-control-static"><?php echo $mi['IP']; ?></div>
213 </div>
214 </div>
215 </div>
216
217 <!-- group and IP address -->
218 <div class="panel panel-info">
219 <div class="panel-body">
220 <div class="form-group">
221 <label><?php echo $Translation['group']; ?></label>
222 <div class="form-control-static"><?php echo $mi['group']; ?></div>
223 </div>
224 </div>
225 </div>
226
227 <?php if($mi['username'] != $adminConfig['adminUsername']){ ?>
228 <!-- change password -->
229 <div class="panel panel-info">
230 <div class="panel-heading">
231 <h3 class="panel-title">
232 <i class="glyphicon glyphicon-asterisk"></i><i class="glyphicon glyphicon-asterisk"></i>
233 <?php echo $Translation['Change your password']; ?>
234 </h3>
235 </div>
236 <div class="panel-body">
237 <fieldset id="change-password">
238 <div id="password-change-form">
239
240 <div class="form-group">
241 <label for="old-password"><?php echo $Translation['Old password']; ?></label>
242 <input type="password" id="old-password" autocomplete="off" class="form-control">
243 </div>
244
245 <div class="form-group">
246 <label for="new-password"><?php echo $Translation['new password']; ?></label>
247 <input type="password" id="new-password" autocomplete="off" class="form-control">
248 <p id="password-strength" class="help-block"></p>
249 </div>
250
251 <div class="form-group">
252 <label for="confirm-password"><?php echo $Translation['confirm password']; ?></label>
253 <input type="password" id="confirm-password" autocomplete="off" class="form-control">
254 <p id="confirm-status" class="help-block"></p>
255 </div>
256
257 <div class="row">
258 <div class="col-md-4 col-md-offset-4">
259 <button id="update-password" class="btn btn-success btn-block" type="button"><i class="glyphicon glyphicon-ok"></i> <?php echo $Translation['Update password']; ?></button>
260 </div>
261 </div>
262
263 </div>
264 </fieldset>
265 </div>
266 </div>
267 <?php } ?>
268
269 </div>
270
271 </div>
272
273
274 <script>
275 $j(function() {
276 <?php
277 /* Is there a notification to display? */
278 $notify = '';
279 if(isset($_GET['notify'])) $notify = addslashes(strip_tags($_GET['notify']));
280 ?>
281 <?php if($notify){ ?> notify('<?php echo $notify; ?>'); <?php } ?>
282
283 $('update-profile').observe('click', function(){
284 post2(
285 '<?php echo basename(__FILE__); ?>',
286 { action: 'saveProfile', email: $F('email'), custom1: $F('custom1'), custom2: $F('custom2'), custom3: $F('custom3'), custom4: $F('custom4'), csrf_token: $F('csrf_token') },
287 'notify', 'profile', 'loader',
288 '<?php echo basename(__FILE__); ?>?notify=<?php echo urlencode($Translation['Your profile was updated successfully']); ?>'
289 );
290 });
291
292 <?php if($mi['username'] != $adminConfig['adminUsername']){ ?>
293 $('update-password').observe('click', function(){
294 /* make sure passwords match */
295 if($F('new-password') != $F('confirm-password')){
296 $('notify').addClassName('Error');
297 notify('<?php echo "{$Translation['error:']} ".addslashes($Translation['password no match']); ?>');
298 $$('label[for="confirm-password"]')[0].pulsate({ pulses: 10, duration: 4 });
299 $('confirm-password').activate();
300 return false;
301 }
302
303 post2(
304 '<?php echo basename(__FILE__); ?>',
305 { action: 'changePassword', oldPassword: $F('old-password'), newPassword: $F('new-password'), csrf_token: $F('csrf_token') },
306 'notify', 'password-change-form', 'loader',
307 '<?php echo basename(__FILE__); ?>?notify=<?php echo urlencode($Translation['Your password was changed successfully']); ?>'
308 );
309 });
310
311 /* password strength feedback */
312 $('new-password').observe('keyup', function(){
313 ps = passwordStrength($F('new-password'), '<?php echo addslashes($mi['username']); ?>');
314
315 if(ps == 'strong')
316 $('password-strength').update('<?php echo $Translation['Password strength: strong']; ?>').setStyle({color: 'Green'});
317 else if(ps == 'good')
318 $('password-strength').update('<?php echo $Translation['Password strength: good']; ?>').setStyle({color: 'Gold'});
319 else
320 $('password-strength').update('<?php echo $Translation['Password strength: weak']; ?>').setStyle({color: 'Red'});
321 });
322
323 /* inline feedback of confirm password */
324 $('confirm-password').observe('keyup', function(){
325 if($F('confirm-password') != $F('new-password') || !$F('confirm-password').length){
326 $('confirm-status').update('<img align="top" src="Exit.gif"/>');
327 }else{
328 $('confirm-status').update('<img align="top" src="update.gif"/>');
329 }
330 });
331 <?php } ?>
332 });
333
334 function notify(msg){
335 $j('#notify').html(msg).fadeIn();
336 window.setTimeout(function(){ /* */ $j('#notify').fadeOut(); }, 15000);
337 }
338 </script>
339
340 <?php
341 /* return icon file name based on given permission value */
342 function permIcon($perm){
343 switch($perm){
344 case 1:
345 return 'member_icon.gif';
346 case 2:
347 return 'members_icon.gif';
348 case 3:
349 return 'approve_icon.gif';
350 default:
351 return 'stop_icon.gif';
352 }
353 }
354 ?>
355
356 <?php include_once("$currDir/footer.php"); ?>
2 $currDir=dirname(__FILE__);
3 include("$currDir/defaultLang.php");
4 include("$currDir/language.php");
5 include("$currDir/lib.php");
6
7 $adminConfig = config('adminConfig');
8
9 /* no access for guests */
10 $mi = getMemberInfo();
11 if(!$mi['username'] || $mi['group'] == $adminConfig['anonymousGroup']){
12 @header('Location: index.php'); exit;
13 }
14
15 /* save profile */
16 if($_POST['action'] == 'saveProfile'){
17 if(!csrf_token(true)){
18 echo $Translation['error:'];
19 exit;
20 }
21
22 /* process inputs */
23 $email=isEmail($_POST['email']);
24 $custom1=makeSafe($_POST['custom1']);
25 $custom2=makeSafe($_POST['custom2']);
26 $custom3=makeSafe($_POST['custom3']);
27 $custom4=makeSafe($_POST['custom4']);
28
29 /* validate email */
30 if(!$email){
31 echo "{$Translation['error:']} {$Translation['email invalid']}";
32 echo "<script>$$('label[for=\"email\"]')[0].pulsate({ pulses: 10, duration: 4 }); $('email').activate();</script>";
33 exit;
34 }
35
36 /* update profile */
37 $updateDT = date($adminConfig['PHPDateTimeFormat']);
38 sql("UPDATE `membership_users` set email='$email', custom1='$custom1', custom2='$custom2', custom3='$custom3', custom4='$custom4', comments=CONCAT_WS('\\n', comments, 'member updated his profile on $updateDT from IP address {$mi[IP]}') WHERE memberID='{$mi['username']}'", $eo);
39
40 // hook: member_activity
41 if(function_exists('member_activity')){
42 $args=array();
43 member_activity($mi, 'profile', $args);
44 }
45
46 exit;
47 }
48
49 /* change password */
50 if($_POST['action'] == 'changePassword' && $mi['username'] != $adminConfig['adminUsername']){
51 if(!csrf_token(true)){
52 echo $Translation['error:'];
53 exit;
54 }
55
56 /* process inputs */
57 $oldPassword=$_POST['oldPassword'];
58 $newPassword=$_POST['newPassword'];
59
60 /* validate password */
61 if(md5($oldPassword) != sqlValue("SELECT `passMD5` FROM `membership_users` WHERE memberID='{$mi['username']}'")){
62 echo "{$Translation['error:']} {$Translation['Wrong password']}";
63 echo "<script>$$('label[for=\"old-password\"]')[0].pulsate({ pulses: 10, duration: 4 }); $('old-password').activate();</script>";
64 exit;
65 }
66 if(strlen($newPassword) < 4){
67 echo "{$Translation['error:']} {$Translation['password invalid']}";
68 echo "<script>$$('label[for=\"new-password\"]')[0].pulsate({ pulses: 10, duration: 4 }); $('new-password').activate();</script>";
69 exit;
70 }
71
72 /* update password */
73 $updateDT = date($adminConfig['PHPDateTimeFormat']);
74 sql("UPDATE `membership_users` set `passMD5`='".md5($newPassword)."', `comments`=CONCAT_WS('\\n', comments, 'member changed his password on $updateDT from IP address {$mi[IP]}') WHERE memberID='{$mi['username']}'", $eo);
75
76 // hook: member_activity
77 if(function_exists('member_activity')){
78 $args=array();
79 member_activity($mi, 'password', $args);
80 }
81
82 exit;
83 }
84
85 /* get profile info */
86 /*
87 $mi already contains the profile info, as documented at:
88 https://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
89
90 custom field names are stored in $adminConfig['custom1'] to $adminConfig['custom4']
91 */
92 $permissions = array();
93 $userTables = getTableList();
94 if(is_array($userTables)) foreach($userTables as $tn => $tc){
95 $permissions[$tn] = getTablePermissions($tn);
96 }
97
98 /* the profile page view */
99 include_once("$currDir/header.php"); ?>
100
101 <div class="page-header">
102 <h1><?php echo sprintf($Translation['Hello user'], $mi['username']); ?></h1>
103 </div>
104 <div id="notify" class="alert alert-success" style="display: none;"></div>
105 <div id="loader" style="display: none;"><i class="glyphicon glyphicon-refresh"></i> <?php echo $Translation['Loading ...']; ?></div>
106
107 <?php echo csrf_token(); ?>
108 <div class="row">
109
110 <div class="col-md-6">
111
112 <!-- user info form -->
113 <div class="panel panel-info">
114 <div class="panel-heading">
115 <h3 class="panel-title">
116 <i class="glyphicon glyphicon-info-sign"></i>
117 <?php echo $Translation['Your info']; ?>
118 </h3>
119 </div>
120 <div class="panel-body">
121 <fieldset id="profile">
122 <div class="form-group">
123 <label for="email"><?php echo $Translation['email']; ?></label>
124 <input type="email" id="email" name="email" value="<?php echo $mi['email']; ?>" class="form-control">
125 </div>
126
127 <?php for($i=1; $i<5; $i++){ ?>
128 <div class="form-group">
129 <label for="custom<?php echo $i; ?>"><?php echo $adminConfig['custom'.$i]; ?></label>
130 <input type="text" id="custom<?php echo $i; ?>" name="custom<?php echo $i; ?>" value="<?php echo $mi['custom'][$i-1]; ?>" class="form-control">
131 </div>
132 <?php } ?>
133
134 <div class="row">
135 <div class="col-md-4 col-md-offset-4">
136 <button id="update-profile" class="btn btn-success btn-block" type="button"><i class="glyphicon glyphicon-ok"></i> <?php echo $Translation['Update profile']; ?></button>
137 </div>
138 </div>
139 </fieldset>
140 </div>
141 </div>
142
143 <!-- access permissions -->
144 <div class="panel panel-info">
145 <div class="panel-heading">
146 <h3 class="panel-title">
147 <i class="glyphicon glyphicon-lock"></i>
148 <?php echo 'Quản lý quyền truy cập';//$Translation['Your access permissions']; ?>
149 </h3>
150 </div>
151 <div class="panel-body">
152
153 <div class="row">
154 <div class="col-xs-2 col-md-1 text-right"><img src="admin/images/stop_icon.gif"></div>
155 <div class="col-xs-10 col-md-5"><?php echo 'Không cho phép';//$Translation['Not allowed']; ?></div>
156 <div class="col-xs-2 col-md-1 text-right"><img src="admin/images/member_icon.gif"></div>
157 <div class="col-xs-10 col-md-5"><?php echo 'Chỉ mình bạn được quyền này';//$Translation['Only your own records']; ?></div>
158 </div>
159 <div class="row">
160 <div class="col-xs-2 col-md-1 text-right"><img src="admin/images/members_icon.gif"></div>
161 <div class="col-xs-10 col-md-5"><?php echo 'Nhóm bạn quản lý';//$Translation['All records owned by your group']; ?></div>
162 <div class="col-xs-2 col-md-1 text-right"><img src="admin/images/approve_icon.gif"></div>
163 <div class="col-xs-10 col-md-5"><?php echo 'Tất cả các quyền';// $Translation['All records']; ?></div>
164 </div>
165
166 <p class="vspacer-lg"></p>
167
168 <div class="table-responsive">
169 <table class="table table-striped table-hover table-bordered" id="permissions">
170 <thead>
171 <tr>
172 <th></th>
173 <!--
174 <th class="text-center"><?php echo $Translation['View']; ?></th>
175 <th class="text-center"><?php echo $Translation['Add New']; ?></th>
176 <th class="text-center"><?php echo $Translation['Edit']; ?></th>
177 <th class="text-center"><?php echo $Translation['Delete']; ?></th>
178
179 -->
180 <th class="text-center"><?php echo 'Xem'; ?></th>
181 <th class="text-center"><?php echo 'Thêm mới'; ?></th>
182 <th class="text-center"><?php echo 'Sửa'; ?></th>
183 <th class="text-center"><?php echo 'Xóa'; ?></th>
184
185 </tr>
186 </thead>
187 <tbody>
188 <?php foreach($permissions as $tn => $perm){ ?>
189 <tr>
190 <td><img src="<?php echo $userTables[$tn][2]; ?>"> <a href="<?php echo $tn; ?>_view.php"><?php echo $userTables[$tn][0]; ?></a></td>
191 <td class="text-center"><img src="admin/images/<?php echo permIcon($perm[2]); ?>" /></td>
192 <td class="text-center"><img src="admin/images/<?php echo ($perm[1] ? 'approve' : 'stop'); ?>_icon.gif" /></td>
193 <td class="text-center"><img src="admin/images/<?php echo permIcon($perm[3]); ?>" /></td>
194 <td class="text-center"><img src="admin/images/<?php echo permIcon($perm[4]); ?>" /></td>
195 </tr>
196 <?php } ?>
197 </tbody>
198 </table>
199 </div>
200 </div>
201 </div>
202
203 </div>
204
205 <div class="col-md-6">
206
207 <!-- group and IP address -->
208 <div class="panel panel-info">
209 <div class="panel-body">
210 <div class="form-group">
211 <label><?php echo $Translation['Your IP address']; ?></label>
212 <div class="form-control-static"><?php echo $mi['IP']; ?></div>
213 </div>
214 </div>
215 </div>
216
217 <!-- group and IP address -->
218 <div class="panel panel-info">
219 <div class="panel-body">
220 <div class="form-group">
221 <label><?php echo $Translation['group']; ?></label>
222 <div class="form-control-static"><?php echo $mi['group']; ?></div>
223 </div>
224 </div>
225 </div>
226
227 <?php if($mi['username'] != $adminConfig['adminUsername']){ ?>
228 <!-- change password -->
229 <div class="panel panel-info">
230 <div class="panel-heading">
231 <h3 class="panel-title">
232 <i class="glyphicon glyphicon-asterisk"></i><i class="glyphicon glyphicon-asterisk"></i>
233 <?php echo $Translation['Change your password']; ?>
234 </h3>
235 </div>
236 <div class="panel-body">
237 <fieldset id="change-password">
238 <div id="password-change-form">
239
240 <div class="form-group">
241 <label for="old-password"><?php echo $Translation['Old password']; ?></label>
242 <input type="password" id="old-password" autocomplete="off" class="form-control">
243 </div>
244
245 <div class="form-group">
246 <label for="new-password"><?php echo $Translation['new password']; ?></label>
247 <input type="password" id="new-password" autocomplete="off" class="form-control">
248 <p id="password-strength" class="help-block"></p>
249 </div>
250
251 <div class="form-group">
252 <label for="confirm-password"><?php echo $Translation['confirm password']; ?></label>
253 <input type="password" id="confirm-password" autocomplete="off" class="form-control">
254 <p id="confirm-status" class="help-block"></p>
255 </div>
256
257 <div class="row">
258 <div class="col-md-4 col-md-offset-4">
259 <button id="update-password" class="btn btn-success btn-block" type="button"><i class="glyphicon glyphicon-ok"></i> <?php echo $Translation['Update password']; ?></button>
260 </div>
261 </div>
262
263 </div>
264 </fieldset>
265 </div>
266 </div>
267 <?php } ?>
268
269 </div>
270
271 </div>
272
273
274 <script>
275 $j(function() {
276 <?php
277 /* Is there a notification to display? */
278 $notify = '';
279 if(isset($_GET['notify'])) $notify = addslashes(strip_tags($_GET['notify']));
280 ?>
281 <?php if($notify){ ?> notify('<?php echo $notify; ?>'); <?php } ?>
282
283 $('update-profile').observe('click', function(){
284 post2(
285 '<?php echo basename(__FILE__); ?>',
286 { action: 'saveProfile', email: $F('email'), custom1: $F('custom1'), custom2: $F('custom2'), custom3: $F('custom3'), custom4: $F('custom4'), csrf_token: $F('csrf_token') },
287 'notify', 'profile', 'loader',
288 '<?php echo basename(__FILE__); ?>?notify=<?php echo urlencode($Translation['Your profile was updated successfully']); ?>'
289 );
290 });
291
292 <?php if($mi['username'] != $adminConfig['adminUsername']){ ?>
293 $('update-password').observe('click', function(){
294 /* make sure passwords match */
295 if($F('new-password') != $F('confirm-password')){
296 $('notify').addClassName('Error');
297 notify('<?php echo "{$Translation['error:']} ".addslashes($Translation['password no match']); ?>');
298 $$('label[for="confirm-password"]')[0].pulsate({ pulses: 10, duration: 4 });
299 $('confirm-password').activate();
300 return false;
301 }
302
303 post2(
304 '<?php echo basename(__FILE__); ?>',
305 { action: 'changePassword', oldPassword: $F('old-password'), newPassword: $F('new-password'), csrf_token: $F('csrf_token') },
306 'notify', 'password-change-form', 'loader',
307 '<?php echo basename(__FILE__); ?>?notify=<?php echo urlencode($Translation['Your password was changed successfully']); ?>'
308 );
309 });
310
311 /* password strength feedback */
312 $('new-password').observe('keyup', function(){
313 ps = passwordStrength($F('new-password'), '<?php echo addslashes($mi['username']); ?>');
314
315 if(ps == 'strong')
316 $('password-strength').update('<?php echo $Translation['Password strength: strong']; ?>').setStyle({color: 'Green'});
317 else if(ps == 'good')
318 $('password-strength').update('<?php echo $Translation['Password strength: good']; ?>').setStyle({color: 'Gold'});
319 else
320 $('password-strength').update('<?php echo $Translation['Password strength: weak']; ?>').setStyle({color: 'Red'});
321 });
322
323 /* inline feedback of confirm password */
324 $('confirm-password').observe('keyup', function(){
325 if($F('confirm-password') != $F('new-password') || !$F('confirm-password').length){
326 $('confirm-status').update('<img align="top" src="Exit.gif"/>');
327 }else{
328 $('confirm-status').update('<img align="top" src="update.gif"/>');
329 }
330 });
331 <?php } ?>
332 });
333
334 function notify(msg){
335 $j('#notify').html(msg).fadeIn();
336 window.setTimeout(function(){ /* */ $j('#notify').fadeOut(); }, 15000);
337 }
338 </script>
339
340 <?php
341 /* return icon file name based on given permission value */
342 function permIcon($perm){
343 switch($perm){
344 case 1:
345 return 'member_icon.gif';
346 case 2:
347 return 'members_icon.gif';
348 case 3:
349 return 'approve_icon.gif';
350 default:
351 return 'stop_icon.gif';
352 }
353 }
354 ?>
355
356 <?php include_once("$currDir/footer.php"); ?>